﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

using System.Web.Script.Services;
namespace JTicket.UI.Service
{
    /// <summary>
    /// Summary description for JT_SubArea
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    [GenerateScriptType(typeof(Model.D_SubArea))]
    public class JT_SubAreaSvc : System.Web.Services.WebService
    {

        [WebMethod]
        public string Add(string AreaCode, string AreaName, string ThCode,string ThName)
        {
            if (!BLL.D_Area.Exists(AreaCode))
            {
                JTicket.Model.D_Area model = new Model.D_Area();
                JTicket.Model.C_TheaterInfo modelTheater = new BLL.C_TheaterInfo().GetModel(ThCode);
                if (modelTheater != null)
                {
                    model.AreaCode = AreaCode;
                    model.AreaName = AreaName;
                    model.ex = "0";
                    model.ey = "0";
                    model.x = "0";
                    model.y = "0";
                    model.ThCode = ThCode;
                    model.ThName = modelTheater.ThName;
                    BLL.D_Area.Add(model);

                    return "添加成功！";
                }
                else
                {
                    return "该场馆名称不存在！";
                }
            }
            else
                return "该分区编号已存在！";
        }
        [WebMethod]
        public string Delete(string AreaCode)
        {
            if (BLL.D_Area.Exists(AreaCode))
            {
                BLL.D_Area.Delete(AreaCode);
                return "删除成功！";
            }
            else
                return "不存在此分区！";
        }
         [WebMethod]
        public string Update(string AreaCode,string AreaName, string ThCode)
        {
            if (BLL.D_Area.Exists(AreaCode))
            {
                JTicket.Model.D_Area model = new Model.D_Area();
                model.AreaCode = AreaCode;
                model.AreaName = AreaName;
                model.ThCode = ThCode;
                BLL.D_Area.Update(model);
                return "修改成功！";
            }
            else
                return "不存在此分区！";
        }

    }
}
